﻿#ifndef CLogOper_H
#define CLogOper_H
/********************************************************************************
** @ Date:2024/04/09
** @ Author: HanJiaXin
** @ Description:日志单例类
** @ Version:1.0.0
** @ ClassName:CLogOper
** @ Fun:
********************************************************************************/
#include "LogModule.h"

enum ELogType
{
	enWorkInfo=1,//系统信息
	enAlarmRecovery,//报警恢复
	enProcessAlarm,//工艺报警
	enSysAlarm,//系统异常报警
	enDevAlarm,//设备故障
	enOperInfo,//操作信息
};

struct SExecLog
{
	QDateTime      m_dLogTime;          //时间
	QString        m_sDevName;
	bool           m_bExecResult;       //操作执行结果  false 失败  true成功
	QString        m_sDescriptionl;     //操作描述
	int            m_nAlarmLevel;       //报警等级 1运行 2正常 3报警 4错误 5硬件故障

	SExecLog()
	{
		m_sDevName = "";
		m_bExecResult = false;
		QString m_sDescriptionl = "";
		int m_nAlarmLevel = -1;
	}
};

class CLogOper
{
public:
	static CLogOper& instance()
	{
		static CLogOper instance;
		return instance;
	}
	LogModule* getLogModule(QString sSceneGuid);//根据场景Guid获取日志控件指针
	void addLogModule(QString sSenceGuid,LogModule* pLogModule);//将传入的日志控件指针统一管理

	void addMsg(QString sSceneGuid, SExecLog sExecLog);//添加日志

private:
	CLogOper();
	~CLogOper();
	
	QMap<QString, LogModule*> m_mapLogModule;//QString为场景Guid 值为日志控件的指针
};
#endif